const path = require("path");
const selectIP = 'http://120.55.72.217'

module.exports = {
    devServer: {
        port: 10012,
        host: '0.0.0.0',
        disableHostCheck: true,
        // 配置跨域请求头，解决开发环境的跨域问题
        headers: {
            "Access-Control-Allow-Origin": "*",
        },
        proxy: {
            "/api": {
                target: selectIP,
                changeOrigin: true,
                logLevel: "debug",
                pathRewrite: {
                    "^/api/": "/"
                }
            }
        }
    },
    productionSourceMap: false,
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
            config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
            config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
        }
        return {
            resolve: {
                alias: {
                    "@": path.resolve(__dirname, "src"),
                },
            },
            output: {
                // 微应用的包名，这里与主应用中注册的微应用名称一致
                library: "VueMicroApp",
                // 将你的 library 暴露为所有的模块定义下都可运行的方式
                libraryTarget: "umd",
                // 按需加载相关，设置为 webpackJsonp_VueMicroApp 即可
                jsonpFunction: `webpackJsonp_VueMicroApp`,
            }
        }
    }
}